package createpattern.builder;

import java.util.ArrayList;
import java.util.List;

/**
 * 套餐
 *
 * @author seer
 * @date 2018/2/5 17:09
 */
public class Meal {
    private List<Item> items = new ArrayList<>();

    public void addItem(Item item) {
        items.add(item);
    }

    public Double getCost() {
        Double sum = items.stream().mapToDouble(item -> item.price()).sum();
        return sum;
    }

    public void showItem() {
        items.forEach(item ->
                System.out.printf("name: %s, price: %s, packing: %s \n", item.name(), item.price(), item.packing())
        );
    }
}
